import axios from 'axios'
import Login from './Apis/Login.js'
import Wx from './Apis/Wx.js'
import CheckPerfect from './Apis/CheckPerfect.js'
import Index from './Apis/Index.js'
import Admin from './Apis/Admin.js'

//所有接口地址的封装
var ApiUrl = {
  'wx': '/parent/Login/getWxjsapiConfig',
  /*wx：API授权接口*/
  'login': {
    'Select': '/parent/login/getSchool',
    'Login': '/parent/login/index',
    'UpdatePwd': '/parent/login/updatePassword',
    'VerifyCode':'/parent/login/sendVerifyCode'
    /*login.Login：登陆接口(post)  login.UpdatePwd 忘记密码(post) login.VerifyCode 获取验证码（post）*/
  },

  'userInfo': {
    /*userInfo.UserInfo：确认信息的显示数据(get)  userInfo.Confirm：确认用户信息(post) userInfo.SetPwd：设置用户支付密码(post)*/
    'UserInfo': '/parent/user/index',
    'Confirm': '/parent/user/confirmMessage',
    'SetPwd': '/parent/user/setVerifyPass',
    
  },

  'index': {
      /*index.Index：显示通知接口  index.productList：显示理财列表接口  index.noticeDetail：通知详情  index.parentIsViewNotice 添加阅读记录     index.WxjsapiConfig：微信支付jdk配置*/
    'Index': '/parent/index/index',
    'productList': '/parent/index/productList',
    'NoticeDetail': '/parent/index/noticeDetail',
    'ParentIsViewNotice': '/parent/index/parentIsViewNotice',
    'Order':'/parent/Pay/Order',
    // 存款
    'Product':'/parent/Index/productDetail',
  
  },
  'admin': {
    /*admin.Info：用户数据 */
    'Info': '/parent/User/userData',
    /*admin.bill：幼儿园账单 */
    'bill': '/parent/user/getSchoolBill',
     /*admin.financeList：资金明细 */
    'financeList': '/parent/User/financeList',
     /*admin.ToList：待办事项 */
    'ToList': '/parent/user/getWaitToList',
     /*admin.Logout：退出登录 */
     'Logout': '/parent/user/logout'
    
    
  },
}
var SessionId = ''
localStorage.getItem('sessionId') ? SessionId = localStorage.getItem('sessionId') : SessionId = sessionStorage.getItem('sessionId');


const ajaxinstance = axios.create({
  timeout: 20000, //响应最长时间
  headers: {
    'SessionId': SessionId
  },
})



// 添加拦截器，处理 公用请求参数，和通用请求头部
ajaxinstance
  .interceptors
  .request
  .use((config) => {
    return config
  }, (error) => {
    Promise.reject(error)
  })
var Api = {
  ...Wx(ajaxinstance, ApiUrl.wx),
  ...Login(ajaxinstance, ApiUrl.login),
  ...CheckPerfect(ajaxinstance, ApiUrl.userInfo),
  ...Index(ajaxinstance, ApiUrl.index),
  ...Admin(ajaxinstance, ApiUrl.admin),
}

export default Api
